<%@page import="java.sql.*"%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Java单选测试题</title>
<style type="text/css">
h1{
	 color:red;
	 text-align: center;
	 
}
.kuang{
	width: 800px;
	margin: auto;
	border: 1px solid gray;
	padding:20px;
	font-size: 16px;
	font-family: monospace;
	line-height: 2;	
}
pre{ 
	margin: 0;
	white-space: pre-wrap;
	word-break: break-all;
}
.timu b{
	font-weight: normal;
}

.timu>div{
	display: flex;
	padding: 6px 0;
	margin: 5px;
}
.timu>div:first-child>b {
	width: 50px;
	text-align: right;
}
.timu>div:nth-child(n+2){
	padding-left: 63px;
}
.timu>div:first-child {
	border: 3px double gray;
	border-radius: 10px;
	padding: 10px;
	
}
.da{
	background-color: #00f2;
	border-radius: 10px;
	color: red;
	font-weight: bold;
}
</style>
</head>
<body>
<h1>Java单选测试题</h1>
<div class='kuang'><% 
int currentPage=1;
int pageSize=10;

String url="jdbc:mysql://localhost:3306/db?serverTimezone=PRC";

//(1)加载驱动
Class.forName("com.mysql.cj.jdbc.Driver");
//(2)创建数据库连接
Connection cn = DriverManager.getConnection(url,"root","12qwas");//  "+first+"
//(3)创建预处理语句对象以执行sql指令
PreparedStatement ps = cn.prepareStatement("select * from ku limit ?,?");
ps.setInt(1, (currentPage-1)*pageSize);
ps.setInt(2, pageSize);
ResultSet rs= ps.executeQuery();
int bh=0;
while(rs.next()){
	String da=rs.getString("r");
	out.println("\t<div class='timu'>");
	out.println("\t\t<div><b>"+ ++bh +"、</b><pre>"+ rs.getString("t")+"</pre></div>");
	out.println("\t\t<div"+(da.equals("A")?" class='da'":"")+"><b>A、</b><pre>"+rs.getString("a")+"</pre></div>");
	out.println("\t\t<div"+(da.equals("B")?" class='da'":"")+"><b>B、</b><pre>"+rs.getString("b")+"</pre></div>");
	out.println("\t\t<div"+(da.equals("C")?" class='da'":"")+"><b>C、</b><pre>"+rs.getString("c")+"</pre></div>");
	out.println("\t\t<div"+(da.equals("D")?" class='da'":"")+"><b>D、</b><pre>"+rs.getString("d")+"</pre></div>");
	out.println("\t</div>");
}
%>

</div>
</body>
</html>